package top.itmeans.yes.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.itmeans.yes.entity.ResourceCategory;
import top.itmeans.yes.mapper.ResourceCategoryMapper;
import top.itmeans.yes.service.ResourceCategoryService;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * <p>
 * 资源分类表 服务实现类
 * </p>
 *
 * @author Yiming.Cao
 * @since 2022-04-28
 */
@Service
public class ResourceCategoryServiceImpl extends ServiceImpl<ResourceCategoryMapper, ResourceCategory> implements ResourceCategoryService {
    @Resource
    private ResourceCategoryMapper resourceCategoryMapper;

    @Override
    public int create(ResourceCategory resourceCategory) {
        resourceCategory.setCreateTime(LocalDateTime.now());
        return resourceCategoryMapper.insert(resourceCategory);
    }

    @Override
    public int update(Long id, ResourceCategory resourceCategory) {
        resourceCategory.setId(id);
        return resourceCategoryMapper.updateById(resourceCategory);
    }

    @Override
    public int delete(Long id) {
        return resourceCategoryMapper.deleteById(id);
    }
}
